from langchain_openai import ChatOpenAI
from globle import envs
from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import ChatPromptTemplate

system_template = "翻译以下文本到 {language}:"
prompt_template = ChatPromptTemplate.from_messages(
    [("system", system_template), ("user", "{text}")]
)
#result = prompt_template.invoke({"language": "中文", "text": "hi"})

# 创建模型
model = ChatOpenAI(
    model="deepseek-chat",  # 或具体模型名
    base_url="https://api.deepseek.com/v1",  # DeepSeek API 地址
)
# 创建解析器
parser = StrOutputParser()

# 创建链
chain = prompt_template | model | parser

# 调用链
r = chain.invoke({"language": "中文", "text": "hi"})
print(r)